<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
	<head>
		<base href="<%=basePath%>">

		<title>添加文章</title>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link rel="stylesheet" type="text/css"
			href="<%=basePath%>jslib/bootstrap/css/bootstrap.css">
		<link rel="stylesheet" type="text/css"
			href="<%=basePath%>css/theme.css">
			<link rel="stylesheet" type="text/css" href="<%=basePath%>jslib/bootstrap/css/bootstrap-datetimepicker.min.css">
		<link rel="stylesheet"
			href="<%=basePath%>jslib/font-awesome/css/font-awesome.css">
		<script src="<%=basePath%>jslib/jquery-1.7.2.min.js"
			type="text/javascript"></script>
		<script src="<%=basePath%>jslib/bootstrap/js/bootstrap.min.js"></script>
		<script src="<%=basePath%>jslib/bootstrap/js/bootstrap-datetimepicker.min.js"></script>
			<script src="<%=basePath%>jslib/bootstrap/js/bootstrap-datetimepicker.zh-CN.js"></script>
            
		<script type="text/javascript">
			$(document).ready(function(e) {
                
				loadfirstnav();
				
				
            });
            
            function loadfirstnav(){
            
            	$.ajax({
					
					type:"post",
					url:"<%=basePath%>sys/art?cmd=ajaxListFirstNav",
					success: function(msg){
					var navfirst=$.parseJSON(msg);
						$("#navfirst").append("<option value='-1'>请选择</option>");
						$("#navsecond").append("<option value='-1'>请选择</option>");
						
						for(var i in navfirst){
							$("#navfirst").append("<option value='"+navfirst[i].nid+"'>"+navfirst[i].name+"</option>");	
						}
					}
				});
            }
			
			function nav(){
					
					var navfirstid = $("#navfirst").val();
					
					
					
					 $("#navsecond").empty();
					
						$.ajax({
							
							type:"post",
							url:"<%=basePath%>sys/art?cmd=ajaxListSecondNav",
							data : "pid=" + navfirstid,
							success : function(msg) {
								var navfir = $.parseJSON(msg);
								$("#navsecond").append("<option value='-1'>请选择</option>");
									for ( var i in navfir) {
									
											$("#navsecond").append("<option value='"+navfir[i].nid+"'>"+navfir[i].name+"</option>");	
										
									}
							}
						});

				}
			
					function check(){
   						 var str = document.getElementById("f_file").value;
    					if(str.length==0)
   					 	{
   						     alert("请选择上传");
      							 return false;
  					    }
  					  return true;
					}

</script>


	</head>

	<body class="content1">
		<div class="header">
			<h1 class="page-title">
				添加文章
			</h1>
		</div>

		<ul class="breadcrumb">
			<li>
				<a href="index.html">文章管理</a>
				<span class="divider">/</span>
			</li>
			<li class="active">
				添加文章
			</li>
		</ul>

		<div class="container-fluid">
				<div class="row-fluid">
				
				
    
				<form method="post" action="<%=basePath%>sys/art?cmd=add" enctype="multipart/form-data">
					<div class="btn-toolbar">
					<input type="hidden" name="cmd" value="add"/>
						<input type="submit" class="btn btn-primary" value="保存 ">
						<a href="<%=basePath%>sys/nav?cmd=listfirst" class="btn">取消</a>
						<input type="hidden" name="artstate" value="0">

					</div>

					<div class="well">
						<div class="tab-pane active in">

							

							
							<label>
								一级导航：
							</label>
							<select id="navfirst" name="firstnavid" onChange="nav()">

							</select>
							<label>
								二级导航：
							</label>
							<select id="navsecond" name="nid">

							</select>

							<label>
								文章标题：
							</label>
							<input type="text" name="title" maxlength="100"
								style="width: 500px;">
							<label>
								发布时间：
							</label>	
								
								<div class="controls input-append date form_date"   data-link-field="dtp_input2" data-link-format="yyyy-mm-dd">
			                    <input size="16" type="text" value="" readonly name="createdate">
			                    <span class="add-on"><i class="icon-remove"></i></span>
								<span class="add-on"><i class="icon-th"></i></span>
			                </div>
							<label>
								图文文章图片：
							</label>
    						<input type="file" name="pic"/>
    						<span style="color:green">${filemsg}</span>
							<label>
								文章简介：
							</label>
							<textarea rows="10" cols="30" name="intro"></textarea><br/>
								作者：
							</label>
							<input type="text" name="author" maxlength="20">

							<input type="hidden" name="artstate" value="0">

						
							


<script type="text/javascript">
   
	$('.form_date').datetimepicker({
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
		autoclose: 1,
		todayHighlight: 1,
		startView: 2,
		minView: 2,
		forceParse: 0,

		 format: "yyyy-mm-dd",
        autoclose: true,
      
        pickerPosition: "bottom-left"
    })
   </script>



							<div style="color: red">
								${msg}
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</body>
</html>
